import VueRouter from 'vue-router'
import PageRouter from './page/'
import ViewsRouter from './views/'
import ProjectRouter from './views/project'
import DetailedListRouter from './views/detailedList'
import SubjectRouter from './views/subject'
import OpinionRouter from './views/opinion'
import MakeRouter from './views/make'
import ReviewRouter from './views/review'
import SystemRouter from './views/system'
import ResultRouter from './views/result'
import AvueRouter from './avue-router'
import PimRouter from './views/pim'
import AchievementRouter from './views/achievement'
import ActivitiRouter from './views/activiti'
import Store from '../store/'
let Router = new VueRouter({
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop
      }
      return {
        x: 0,
        y: to.meta.savedPosition || 0
      }
    }
  },
  routes: [].concat([])
})
AvueRouter.install(Router, Store)
Router.$avueRouter.formatRoutes(Store.state.user.menu, true)
Router.addRoutes([
  ...PageRouter,
  ...ViewsRouter,
  ...ProjectRouter,
  ...SubjectRouter,
  ...OpinionRouter,
  ...MakeRouter,
  ...ReviewRouter,
  ...PimRouter,
  ...SystemRouter,
  ...DetailedListRouter,
  ...ResultRouter,
  ...AchievementRouter,
  ...ActivitiRouter
]);
export default Router
